package wei.xinya.pattern.behavioral.template;

import java.util.Vector;

abstract class Application {
    private final Vector<Document> documents = null;

    private boolean canOpenDocument(String docName) {
        /*判断是否可以打开指定文档，返回真值表示可以打开，返回假值表示不可以打开*/
        return true;
    }

    private void addDocument(Document document) {
        documents.add(document);
    }

    abstract Document doCreateDocument();

    public void openDocument(String docName) {
        if (!canOpenDocument(docName)) {
            System.out.println("文档无法打开！");
            return;
        }
        Document adc = doCreateDocument();
        adc.open(docName);
        adc.read(docName);
        addDocument(adc);
    }
}
